<template>
    <div class="getCoupons">
        <div class="top">
            <div class="get">
                <img src="https://image.hezongyy.com/pcimage/119h5/app_coupons2.png" alt="" v-show="this.isGet==0" @click='getAll()'>
                <img src="https://image.hezongyy.com/pcimage/119h5/app_coupons3.png" alt="" v-show="this.isGet==1" @click='toPerson()'>
                <!-- <img src="https://image.hezongyy.com/pcimage/119h5/app_coupons5.png" alt="" v-show="this.isGet==1"> -->
            </div>
            <div class="tips">
                <img src="https://image.hezongyy.com/pcimage/119h5/app_coupons4_1.png" alt="">
            </div>
        </div>
    </div>
</template>

<script>
import url from "../../axios/apiUrl";
import { postRequest } from "../../api/index";
import { getRequest } from "../../api/indexGet";
export default {
  data() {
    return {
      isGet: 0 //是否领取优惠券
    };
  },
  created() {
    getRequest(url.isGetOver).then(res => {
      if (res.data.code == "000000") {
        this.isGet = res.data.content;
      }
    });
  },
  methods: {
    toPerson() {
      window.location.href=this.pathURL+'nativeApp/couponCenter'
    },
    // 一键领取
    getAll() {
      getRequest(url.getOver).then(res => {
        if (res.data.content) {
          this.isGet = 1;
        }else if(res.data.message=='系统异常'){
          this.$toast("网络异常，请稍后再试");
        }else {
          this.$toast(res.data.message);
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
.getCoupons {
  width: 100%;
  background-color: #595ff8;
  min-height: 100%;
  background-size: 100% 100%;
  .top {
    padding-top: 1592px;
    width: 750px;
    min-height: 0;
    background: url("https://image.hezongyy.com/pcimage/119h5/app_coupons1.jpg")
      no-repeat center;
    background-size: 100% 100%;
    .get {
      text-align: center;
      img {
        width: 590px;
        height: 287px;
      }
    }
    .tips {
      text-align: center;
      img {
        width: 710px;
        height: 314px;
      }
    }
  }
}
</style>